package com.icinfo.cloud.provider.punish.ucase.casemain.dto;

import cn.hutool.core.util.StrUtil;
import com.icinfo.cloud.provider.common.exception.BusinessException;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@Data

public class PoliceAdjudicationModifyDto {
    /****
     *事项代码
     **/
    @NotNull
    private String itemCode;
    /****
     *计分依据
     **/
    private String scoringBasis;
    /****
     *计分依据条号
     **/
    private String scoringArticleNumber;
    /****
     *计分依据款号
     **/
    private String scoringStyleNumber;
    /****
     *计分依据项号
     **/
    private String scoringItemNumber;
    /****
     *裁量基准
     **/
    @NotNull
    private String discretionaryBasis;
    /**
     * 扣分标准
     */
    @Min(value = 1, message = "扣分标准不能低于1分")
    @Max(value = 12, message = "扣分标准不能高于12分")
    private Integer licenseScore;

    /**
     * 检查记分依据与扣分标准的填写情况
     */
    public void checkScoringBasis() {
        if (StrUtil.isNotBlank(this.scoringBasis) && Objects.isNull(this.licenseScore)) {
            throw new BusinessException("请填写扣分标准！");
        }
        if (Objects.nonNull(this.licenseScore) && StrUtil.isBlank(this.scoringBasis)) {
            throw new BusinessException("存在扣分标准时，记分依据必填！");
        }
    }
}
